package com.woniuxy.vuetest.controller;

import com.woniuxy.vuetest.entity.User;
import com.woniuxy.vuetest.result.ResponseResult;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @Author: linKe
 * @Date: 2021/11/21 16:59
 * @FileName: UserController
 * @version: 1.0
 * @Description: 描述
 */
@RequestMapping("/user")
@RestController
public class UserController {
    /**
     * 返回所有结果
     *
     * @return 用户结果集
     */
    @GetMapping("/all")
    public List<User> all() {
        return Arrays.asList(
                new User(1001, "李寻欢1", new Date(), "青云山1"),
                new User(1002, "李寻欢2", new Date(), "青云山2"),
                new User(1003, "李寻欢3", new Date(), "青云山3"),
                new User(1004, "李寻欢4", new Date(), "青云山4"),
                new User(1005, "李寻欢5", new Date(), "青云山5")
        );
    }

    /**
     * 修改用户
     * @param user 用户
     * @return  返回结果集
     */
    @PostMapping("/update")
    public ResponseResult<Boolean> user(@RequestBody User user){
        System.out.println(user);
        //假设数据库修改成功
        return new ResponseResult<Boolean>(200,"删除成功",true);
    }

}
